<template>
  <div>
    <!-- 新增排班--批量排班 -->
    <Dialog
      ref="schedule"
      dialogCls="mydlgg"
      headerCls="mydlgg-head"
      footerCls="mydlgg-foot"
      :dialogStyle="{ width: '1000px' }"
      :modal="true"
      borderType="thin"
      @close="close"
    >
      <div slot="header">
        <span class="headerIcon newlyAdded"></span>
        <span class="titleStyle">批量排班</span>
      </div>

      <div class="insidePadding">
        <!-- 这个div必须保留 -->
        <fieldset class="fieldsetStyle" style="padding:0">
          <!-- <legend>
                                  <b style="color:#293569">选择时段类型</b>
                              </legend>-->
          <!-- fieldset、legend如果需要带边框加标题的容器这俩标签必须保留 -->

          <div class="upContent" style="height: 300px">
            <div class="borderGray leftCont">
              <sidebar-dept
                ref="gridModel"
                :treeHeight="treeHeight1"
                :treeId="'gridModel'"
                :userIds="userIds"
              />
            </div>

            <div class="centerCont">
              <LinkButton btnCls="c1" class="rightWard" @click="toRight"
                >》》
              </LinkButton>

              <LinkButton btnCls="c1" class="leftWard" @click="toLeft"
                >《《
              </LinkButton>
              <p>当前人数：{{ lr.peopleTotal }}人</p>
            </div>
            <!-- 右上角表格 -->
            <div class="borderGray rightCont" style="width: 550px">
              <DataGrid
                :data="lr.peopleData"
                style="height:100%;width: 100%"
                :pagination="true"
                :pageSize="100"
                :total="lr.peopleTotal"
              >
                <GridColumn field="ck" :width="40" align="center">
                  <template slot="header" slot-scope="scope">
                    <CheckBox
                      class="cbs_15"
                      v-model="allChecked"
                      @checkedChange="onAllCheckedChange($event)"
                    ></CheckBox>
                  </template>
                  <template slot="body" slot-scope="scope">
                    <CheckBox
                      class="cbs_15"
                      v-model="scope.row.selected"
                      @checkedChange="onCheckedChange($event)"
                    ></CheckBox>
                  </template>
                </GridColumn>
                <GridColumn
                  field="userNo"
                  title="工号"
                  align="center"
                ></GridColumn>
                <GridColumn
                  field="userName"
                  title="姓名"
                  align="center"
                ></GridColumn>
                <GridColumn
                  field="deptName"
                  title="部门"
                  align="center"
                ></GridColumn>
              </DataGrid>
            </div>
          </div>
        </fieldset>
        <div style="height:10px"></div>
        <Tabs
          ref="tabs"
          style="height:100px;"
          :plain="true"
          headerHeight="30px"
          @tabSelect="tabTitle = $event.title"
        >
          <TabPanel
            :title="'规律班次排班'"
            style="border: 1px solid #b8b7bc;border-top: 0;"
          >
            <div style="padding:10px; margin-top: 10px;">
              <div style="display: flex; padding-right: 10px">
                <div class="marginBottom8" >
                  <Label for="beginDateGuiLv">开始日期</Label>
                  <DateBox
                    inputId="beginDateGuiLv"
                    v-model="beginDateGuiLv"
                    format="yyyy-MM-dd"
                    :editable="false"
                  ></DateBox>
                </div>
                <div class="marginBottom8" >
                  <Label for="endDateGuiLv">结束日期</Label>
                  <DateBox
                    inputId="endDateGuiLv"
                    v-model="endDateGuiLv"
                    format="yyyy-MM-dd"
                    :editable="false"
                  ></DateBox>
                </div>
                <div class="marginBottom8" >
                  <Label>选择班次</Label>
                  <ComboGrid
                    valueField="id"
                    textField="name"
                    :virtualScroll="true"
                    :data="dataGuiLv"
                    v-model="banCiGuiLv"
                    :panelStyle="panelStyle"
                  >
                    <DataGrid slot="grid" :border="false" class="grid-border">
                      <GridColumn
                        field="id"
                        title="编号"
                        align="center"
                      ></GridColumn>
                      <GridColumn
                        field="name"
                        title="名称"
                        align="center"
                      ></GridColumn>
                    </DataGrid>
                  </ComboGrid>
                </div>
              </div>
            </div>
          </TabPanel>
          <TabPanel
            :title="'普通班次排班'"
            style="border: 1px solid #b8b7bc;border-top: 0;"
          >
            <div style="padding:10px; margin-top: 10px;">
              <div style="display: flex">
                <div class="marginBottom8">
                  <Label for="beginDatePuTong">开始日期</Label>
                  <DateBox
                    inputId="beginDatePuTong"
                    v-model="beginDatePuTong"
                    format="yyyy-MM-dd"
                    :editable="false"
                  ></DateBox>
                </div>
                <div class="marginBottom8">
                  <Label for="endDatePuTong">结束日期</Label>
                  <DateBox
                    inputId="endDatePuTong"
                    v-model="endDatePuTong"
                    format="yyyy-MM-dd"
                    :editable="false"
                  ></DateBox>
                </div>
                <div class="marginBottom8">
                  <Label>选择班次</Label>
                  <ComboGrid
                    valueField="id"
                    textField="name"
                    :virtualScroll="true"
                    :data="dataPuTong"
                    v-model="banCiPuTong"
                    :panelStyle="panelStyle"
                  >
                    <DataGrid slot="grid" :border="false" class="grid-border">
                      <GridColumn
                        field="id"
                        title="编号"
                        align="center"
                      ></GridColumn>
                      <GridColumn
                        field="name"
                        title="名称"
                        align="center"
                      ></GridColumn>
                    </DataGrid>
                  </ComboGrid>
                </div>
              </div>
            </div>
          </TabPanel>
          <!-- <TabPanel
                                :title="'启用个人班次和规则设置'"
                                style="border: 1px solid #b8b7bc;border-top: 0;"
                              >
                                <fieldset
                                class="fieldsetStyle"
                                  style="margin:10px;padding: 10px;"
                                >
                                  <div style="display:flex;justify-content:space-between;">
                                    <div style="margin-bottom:10px">
                                      <Label>选择班次</Label>

                                      <ComboGrid
                                              valueField="id"
                                              textField="name"
                                              :virtualScroll="true"
                                              :data="dataPuTong"
                                              v-model="banCiGeRen"
                                      >
                                          <DataGrid slot="grid" :border="false" class="grid-border">
                                              <GridColumn
                                                      field="id"
                                                      title="编号"
                                                      align="center"
                                              ></GridColumn>
                                              <GridColumn
                                                      field="name"
                                                      title="名称"
                                                      align="center"
                                              ></GridColumn>
                                          </DataGrid>
                                      </ComboGrid>
                                    </div>
                                    <div style="margin-bottom:10px">
                                      <Label>每周的固定休息日</Label>
                                      <ComboGrid
                                              valueField="id"
                                              textField="name"
                                              :virtualScroll="true"
                                              v-model="restDay"
                                              :data="[
                                                { id: '1', name: '星期一' },
                                                { id: '2', name: '星期二' },
                                                { id: '3', name: '星期三' },
                                                { id: '4', name: '星期四' },
                                                { id: '5', name: '星期五' },
                                                { id: '6', name: '星期六' },
                                                { id: '7', name: '星期日' }
                                              ]"
                                      >
                                          <DataGrid slot="grid" :border="false" class="grid-border">
                                              <GridColumn
                                                      field="id"
                                                      title="编号"
                                                      align="center"
                                              ></GridColumn>
                                              <GridColumn
                                                      field="name"
                                                      title="名称"
                                                      align="center"
                                              ></GridColumn>
                                          </DataGrid>
                                      </ComboGrid>
                                    </div>
                                    <div style="margin-bottom:10px">
                                      <Label>工作日无有效考勤记录时记</Label>
                                      <ComboGrid
                                              valueField="id"
                                              textField="name"
                                              :virtualScroll="true"
                                              v-model="recordType"
                                              :data="[
                                                { id: '1', name: '休息' },
                                                { id: '2', name: '矿工' }
                                              ]"
                                      >
                                          <DataGrid slot="grid" :border="false" class="grid-border">
                                              <GridColumn
                                                      field="id"
                                                      title="编号"
                                                      align="center"
                                              ></GridColumn>
                                              <GridColumn
                                                      field="name"
                                                      title="名称"
                                                      align="center"
                                              ></GridColumn>
                                          </DataGrid>
                                      </ComboGrid>
                                    </div>
                                  </div>

                                  <div style="line-height: 20px;display: flex;align-items:center;">
                                    <Label for="n1">每人每天最多能连上</Label>
                                    <NumberBox
                                      inputId="n1"
                                      v-model="mostWorkDay"
                                      :spinners="true"
                                      style="width:60px;"
                                    ></NumberBox>
                                    <span class="inputStyle2">个班</span>
                                    <span>考勤一次算满勤</span>
                                    <input
                                      type="checkbox"
                                      name="dining"
                                      value="1"
                                      v-model="oneInFullAttendance"
                                      class="inputStyle2"
                                    />
                                    <span>不考勤也算满勤</span>
                                    <input
                                      type="checkbox"
                                      name="dining"
                                      value="1"
                                      v-model="zeroInFullAttendance"
                                      class="inputStyle2"
                                    />
                                    <span>计算加班</span>
                                    <input
                                      type="checkbox"
                                      name="dining"
                                      value="1"
                                      v-model="computeOverTime"
                                      class="inputStyle2"
                                    />
                                    <span>计算请假</span>
                                    <input
                                      type="checkbox"
                                      name="dining"
                                      value="1"
                                      v-model="computeLeave"
                                      class="inputStyle2"
                                    />
                                    <span>节假日有效</span>
                                    <input
                                      type="checkbox"
                                      name="dining"
                                      value="1"
                                      v-model="festival"
                                      class="inputStyle2"
                                    />
                                  </div>
                                  <p style="color:#666">
                                    （为选择的人员, 启用员工维护中的个人班次和规则设置）
                                  </p>
                                </fieldset>
                                <p style="padding:0 20px;color:#666">
                                  启用个人班次和规则的员工,一般不用再进行排班,详细信息可到员工维护中查询
                                </p>
                              </TabPanel>-->
        </Tabs>
      </div>

      <div slot="footer" style="border:none">
        <div class="footerDiv">
          <!-- footer、footerDiv这两个div必须保留 -->
          <LinkButton @click="submitSchedule" class="saveBtn">保存</LinkButton>
          <LinkButton @click="closeSchedule" class="cancelBtn">返回</LinkButton>
        </div>
      </div>
    </Dialog>

    <!--排班错误详情-->
    <Dialog
      ref="errorXq"
      dialogCls="mydlgg"
      headerCls="mydlgg-head"
      footerCls="mydlgg-foot"
      :dialogStyle="{ width: '720px', marginTop: '50px' }"
      :modal="true"
      borderType="thin"
    >
      <div slot="header">
        <span class="headerIcon newlyAdded"></span>
        <span class="titleStyle">排班错误详情</span>
      </div>
      <div class="insidePadding">
        <!-- 这个div必须保留 -->
        <fieldset class="fieldsetStyle">
          <!-- 表格容器   -->
          <div style="height: 450px">
            <ag-grid-vue
              style="width: 100%; height: 100%;"
              class="ag-theme-balham"
              :rowData="err.xqRowData"
              :columnDefs="err.xqColumnDefs"
            ></ag-grid-vue>
          </div>
        </fieldset>
      </div>
    </Dialog>
  </div>
</template>

<script>
import moment from "moment";
import cfg from "@/config/config";
import userApi from "@/api/user";
import scheduleApi from "@/api/schedule/schedule";
import sidebarDept from "@/components/dept/sidebarDept";
import { tableBoxHeight } from "@/api/communal";
import BdGrid from "@/components/grid";
import dateUtil from "@/utils/dateUtils";
import reqwest from "reqwest";
import { AgGridVue } from "ag-grid-vue";
import sys from "@/api/sys";

export default {
  props: {
    parentSearch: Function,
    userIds: String,
    isFatherPage: Boolean
  },
  components: {
    sidebarDept,
    BdGrid,
    AgGridVue
  },
  name: "",
  data() {
    return {
      isFatherPageN: false,
      treeHeight1: "height:226px", //批量排班弹窗-左侧树高
      // 下拉框样式
      panelStyle: {
        height: "auto",
        maxHeight: "140px",
        borderWidth: "1px",
        borderColor: "#ccc",
        borderStyle: "solid"
      },
      description: "", //原因
      //checkedRows:[],
      //开始日期
      beginYear: new Date().getFullYear() + "",
      beginMonth: new Date().getMonth() + 1 + "",

      //结束日期
      endYear: new Date().getFullYear() + "",
      endMonth: new Date().getMonth() + 1 + "",
      /*录入界面数据*/
      lr: {
        rowHeight: 30,
        /*排班人员表格*/
        peopleData: [],
        peopleTotal: 0
      },
      // 弹窗表格属性
      gridOptions: null,
      autoGroupColumnDef: null,
      defaultColDef: {
        //默认渲染
        editable: false, //为true全部表格可编辑
        resizable: true //默认列定义
        // cellStyle: {
        //   "border-right-color": "#BDC3C7",
        //   "border-right-style": "solid",
        //   "border-right-width": "1px"
        // },
      },
      //Grid选中排班编号
      selectRow: [],
      total: 100,
      pageSize: 20,
      rowHeight: 30,

      columnDefs: [],
      rowData: [],
      // 下拉框属性
      dataGuiLv: [],
      dataPuTong: [],

      mostDay: 10,
      /*复选框*/
      allChecked: false,
      rowClicked: false,
      tabTitle: "规律班次排班",
      //规律
      radioGuiLv: 2,
      banCiGuiLv: "",
      beginDateGuiLv: dateUtil.getFirstDay(),
      endDateGuiLv: dateUtil.getLastDay(),
      //普通
      radioPuTong: 2,
      banCiPuTong: "",
      beginDatePuTong: dateUtil.getFirstDay(),
      endDatePuTong: dateUtil.getLastDay(),
      //个人
      banCiGeRen: [],
      restDay: [6, 7],
      recordType: 1,
      mostWorkDay: 1,
      oneInFullAttendance: false,
      zeroInFullAttendance: false,
      computeOverTime: false,
      computeLeave: false,
      festival: false,
      //错误详情
      err: {
        xqRowData: [],
        xqColumnDefs: [
          { headerName: "工号", field: "userNo", width: 100 },
          { headerName: "姓名", field: "userName", width: 100 },
          { headerName: "部门", field: "deptName", width: 200 },
          { headerName: "错误信息", field: "errorMsg", width: 350 }
        ]
      }
    };
  },
  mounted() {
    this.$refs.errorXq.close();
    scheduleApi.getScheduleGuiLv().then(res => {
      if (res.code == 200) {
        if (res.result.length != 0) {
          this.dataGuiLv = res.result;
          this.banCiGuiLv = null; //res.result[0].id;
        }
      } else {
        this.$messager.alert({
          title: "出现异常",
          icon: "error",
          msg: res.message
        });
      }
    });
    scheduleApi.getSchedulePuTong().then(res => {
      if (res.code == 200) {
        if (res.result.length != 0) {
          this.dataPuTong = res.result;
          this.banCiPuTong = null; //res.result[0].id;
          this.banCiByDate = null; //res.result[0].id;
        }
      } else {
        // 只提示一个登陆失败就行(规律班次提示了)
        // this.$messager.alert({
        //   title: "出现异常",
        //   icon: "error",
        //   msg: res.message
        // });
      }
    });
    this.$refs.schedule.close();
  },
  computed: {
    checkedRows() {
      return this.lr.peopleData.filter(row => row.selected);
    }
  },
  methods: {
    // 新增排班
    addSchedule() {
      console.log(this.userIds);
      let deptIds = null;
      this.isFatherPageN = this.isFatherPage;
      if (this.userIds != null && this.isFatherPageN == true) {
        // 把表格的人员放到右侧表格
        let param = {
          deptIds: deptIds,
          userIds: this.userIds
        };
        this.$loading("获取人员...");
        userApi.getUserInfoList(param).then(res => {
          this.$loading.close();
          if (res.code == 200) {
            let newUser = res.result;
            newUser = newUser.filter(row => {
              return !this.lr.peopleData.find(
                check => row.userSerial == check.userSerial
              );
            });
            if (newUser != null && newUser.length != 0) {
              this.allChecked = false;
            }
            this.lr.peopleData.push(...newUser);
            this.lr.peopleTotal = this.lr.peopleData.length;
            // 让表格的人员为全选状态
            this.$refs.gridModel.selectAll();
          } else {
            this.$messager.alert({
              title: "异常错误",
              icon: "error",
              msg: "加载列表失败!"
            });
          }
        });
      }
      this.$refs.schedule.open();
    },
    close() {
      this.clearData();
    },
    toRight() {
      let tab = this.$refs.gridModel.selectTab;
      let deptIds = null;
      let userIds = null;
      //判断tab的选择是部门还是人员
      if (tab == 1) {
        deptIds = this.$refs.gridModel.getSelectDeptIds();
        console.log(deptIds);

        if (deptIds == null || deptIds == "") {
          this.$messager.alert({
            title: "系统提示",
            icon: "warning",
            msg: "请勾选要排班的部门!"
          });
          return false;
        }
      } else {
        userIds = this.$refs.gridModel.getSelectUserIds();
        // console.log(userIds);
        if (userIds == null || userIds == "") {
          this.$messager.alert({
            title: "系统提示",
            icon: "warning",
            msg: "请勾选要排班的人员!"
          });
          return false;
        }
      }
      //整理请求的数据
      let param = {
        deptIds: deptIds,
        userIds: userIds
      };
      this.$loading("获取人员...");
      userApi.getUserInfoList(param).then(res => {
        this.$loading.close();
        if (res.code == 200) {
          let newUser = res.result;
          newUser = newUser.filter(row => {
            return !this.lr.peopleData.find(
              check => row.userSerial == check.userSerial
            );
          });
          if (newUser != null && newUser.length != 0) {
            this.allChecked = false;
          }
          this.lr.peopleData.push(...newUser);
          this.lr.peopleTotal = this.lr.peopleData.length;
        } else {
          this.$messager.alert({
            title: "异常错误",
            icon: "error",
            msg: "加载列表失败!"
          });
        }
      });
    },
    toLeft() {
      if (this.allChecked) {
        this.lr.peopleData = [];
        this.allChecked = false;
      } else {
        this.lr.peopleData = this.lr.peopleData.filter(a => a.selected != true);
      }
      this.lr.peopleTotal = this.lr.peopleData.length;
    },
    onAllCheckedChange(checked) {
      if (this.rowClicked) {
        return;
      }
      this.lr.peopleData = this.lr.peopleData.map(row => {
        return Object.assign({}, row, {
          selected: checked
        });
      });
    },
    onCheckedChange(checked) {
      this.allChecked = this.checkedRows.length === this.lr.peopleData.length;
      this.rowClicked = true;
      this.$nextTick(() => (this.rowClicked = false));
    },
    //提交排班
    submitSchedule() {
      let param = {};

      // const tabTitle = this.$refs.tabs.getPanelIndex() == 0 ? "规律班次排班" : "普通班次排班";

      const userSerial = this.lr.peopleData.map(res => {
        return res.userSerial;
      });
      if (userSerial == "" || userSerial == null) {
        this.$messager.alert({
          title: "操作提示",
          icon: "warning",
          msg: "请将用户添加到右侧表格中!"
        });
        return;
      }

      if (this.tabTitle == "规律班次排班") {
        let beginDateGuiLv = moment(this.beginDateGuiLv).format("YYYY-MM-DD");
        let endDateGuiLv = moment(this.endDateGuiLv).format("YYYY-MM-DD");
        if (
          beginDateGuiLv == "" ||
          beginDateGuiLv == "Invalid date" ||
          beginDateGuiLv == null
        ) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "请选择规律排班开始日期!"
          });
          return;
        }
        if (
          endDateGuiLv == "" ||
          endDateGuiLv == "Invalid date" ||
          this.endDateGuiLv == null
        ) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "请选择规律排班结束日期!"
          });
          return;
        }
        //console.log(this.beginDateGuiLv > this.endDateGuiLv)
        if (beginDateGuiLv > endDateGuiLv) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "规律排班结束日期不得小于开始日期!"
          });
          return;
        }
        if (this.banCiGuiLv == "" || this.banCiGuiLv == null) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "请选择规律排班班次!"
          });
          return;
        }

        //规律排班参数
        param = {
          userSerial: userSerial.join(","),
          banCi: this.banCiGuiLv,
          beginDate: beginDateGuiLv,
          endDate: endDateGuiLv
        };
        this.$loading("录入排班中...");
        //发送请求
        scheduleApi.addScheduleGuiLv(param).then(res => {
          this.$loading.close();
          if (res.code == 200) {
            this.tabTitle = '规律班次排班';
            this.parentSearch();
            // 说明没有错误信息
            if (res.result.length <= 0) {
              this.$messager.alert({
                title: "操作提示",
                icon: "success",
                msg: "规律班次排班成功!"
              });
              this.clearData();
              // 含有错误信息
            } else {
              this.$messager.confirm({
                title: "系统提示",
                msg: "录入失败名单,点击确定查看详情。",
                result: r => {
                  if (r) {
                    this.err.xqRowData = res.result;
                    this.$refs.errorXq.open();
                  }
                }
              });
            }
          } else {
            this.$messager.alert({
              title: "出现异常",
              icon: "error",
              msg: res.message
            });
          }
        });
      } else if (this.tabTitle == "普通班次排班") {
        let beginDatePuTong = moment(this.beginDatePuTong).format("YYYY-MM-DD");
        let endDatePuTong = moment(this.endDatePuTong).format("YYYY-MM-DD");

        if (
          beginDatePuTong == "" ||
          beginDatePuTong == "Invalid date" ||
          beginDatePuTong == null
        ) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "请选择普通排班开始日期!"
          });
          return;
        }
        if (
          endDatePuTong == "" ||
          endDatePuTong == "Invalid date" ||
          endDatePuTong == null
        ) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "请选择普通排班结束日期!"
          });
          return;
        }
        if (beginDatePuTong > endDatePuTong) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "普通排班结束日期不得小于开始日期!"
          });
          return;
        }
        if (this.banCiPuTong == "" || this.banCiPuTong == null) {
          this.$messager.alert({
            title: "操作提示",
            icon: "warning",
            msg: "请选择普通班次!"
          });
          return;
        }
        //普通排班参数
        param = {
          userSerial: userSerial.join(","),
          banCi: this.banCiPuTong,
          beginDate: beginDatePuTong,
          endDate: endDatePuTong
        };
        this.$loading("录入排班中...");
        //发送请求
        scheduleApi.addSchedulePuTong(param).then(res => {
          this.$loading.close();
          if (res.code == 200) {
            this.tabTitle = '规律班次排班';
            this.parentSearch();

            console.log(res.result)

            if (res.result.length <= 0) {
              this.$messager.alert({
                title: "操作提示",
                icon: "success",
                msg: "普通班次排班成功!"
              });
              this.clearData();
            } else {
              this.$messager.confirm({
                title: "系统提示",
                msg: "录入失败名单,点击确定查看详情。",
                result: r => {
                  if (r) {
                    this.err.xqRowData = res.result;
                    this.$refs.errorXq.open();
                  }
                }
              });
            }
          } else {
            this.$messager.alert({
              title: "操作提示",
              icon: "error",
              msg: res.message
            });
          }
        });
      }
      // else {
      //启用个人

      //   //选择班次
      //   if (
      //     this.banCiGeRen.length == 0 ||
      //     this.banCiGeRen == null ||
      //     this.banCiGeRen == ""
      //   ) {
      //     this.$messager.alert({
      //       title: "操作提示",
      //       icon: "warning",
      //       msg: "请选择班次!"
      //     });
      //     return;
      //   }
      //   //固定休息日
      //   if (
      //     this.restDay.length == 0 ||
      //     this.restDay == null ||
      //     this.restDay == ""
      //   ) {
      //     this.$messager.alert({
      //       title: "操作提示",
      //       icon: "warning",
      //       msg: "请选择固定休息日!"
      //     });
      //     return;
      //   }
      //   //最多工作日
      //   if (this.mostDay == 0 || this.mostDay == null || this.mostDay == "") {
      //     this.$messager.alert({
      //       title: "操作提示",
      //       icon: "warning",
      //       msg: "请输入每人每天最多能连上班天数!"
      //     });
      //     return;
      //   }
      //   //规律排班参数
      //   param = {
      //     userSerial: userSerial.join(","),
      //     banCi: this.banCiGeRen.join(","),
      //     restDay: this.restDay.join(","),
      //     recordType: this.recordType,
      //     mostWorkDay: this.mostWorkDay,
      //     oneInFullAttendance: this.oneInFullAttendance ? 1 : 0,
      //     zeroInFullAttendance: this.zeroInFullAttendance ? 1 : 0,
      //     computeOverTime: this.computeOverTime ? 1 : 0,
      //     computeLeave: this.computeLeave ? 1 : 0,
      //     festival: this.festival ? 1 : 0
      //   };
      //   //发送请求
      //   scheduleApi.addScheduleGeRen(param).then(res => {
      //     if (res.code == 200) {
      //       if (res.result > 0) {
      //         this.$messager.alert({
      //           title: "操作提示",
      //           icon: "success",
      //           msg: "启用个人班次排班成功!"
      //         });
      //       } else {
      //         this.$messager.alert({
      //           title: "操作提示",
      //           icon: "error",
      //           msg: "启用个人班次排班失败!"
      //         });
      //       }
      //     } else {
      //       this.$messager.alert({
      //         title: "操作提示",
      //         icon: "error",
      //         msg: "出现异常:" + res.message
      //       });
      //     }
      //   });
      // }
    },

    closeSchedule() {
      // console.log("关闭");
      this.clearData();
    },
    clearData() {
      this.allChecked = false;
      this.rowClicked = false;
      //this.checkedRows = [];

      this.lr.peopleData = [];
      this.lr.peopleTotal = 0;

      this.banCiGuiLv = null; //this.dataGuiLv[0].id;
      this.beginDateGuiLv = dateUtil.getFirstDay();
      this.endDateGuiLv = dateUtil.getLastDay();

      this.banCiPuTong = null; //this.dataPuTong[0].id;
      this.beginDatePuTong = dateUtil.getFirstDay();
      this.endDatePuTong = dateUtil.getLastDay();

      this.$refs.gridModel.setTabs(0);
      this.isFatherPageN = false;
      this.$refs.schedule.close();
    }
  }
};
</script>

<style scoped></style>
